package ObserverPattern.example;

public class Main {
    public static void main(String[] args) {
        // 定义主题
        NumberGenerator generator = new RandomNumberGenerator();

        // 定义观察者
        Observer observer1 = new DigitObserver();
        Observer observer2 = new GraphObserver();

        // 注册订阅
        generator.addObserver(observer1);
        generator.addObserver(observer2);

        // 发布消息
        generator.execute();
    }
}
